package com.me.backend.api.rest.resources;

import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "LossTypes resource")
@RestController
public class LossTypeResource {
    @CrossOrigin
    @RequestMapping(value = "/lossTypes", method = RequestMethod.GET, produces = "application/json")
    @ApiOperation(value = "fetch lossTypes")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success", response = List.class)
    })
    public List<String> lossTypes() {
        return Lists.newArrayList("food", "glass");
    }

    @CrossOrigin
    @RequestMapping(value = "/subLossTypes", method = RequestMethod.GET, produces = "application/json")
    @ApiOperation(value = "fetch lossTypes")
    @ApiResponses(value = {
            @ApiResponse(code = 200, message = "Success", response = List.class)
    })
    public List<String> subLossTypes(@RequestParam String lossType) {
        if ("food".equalsIgnoreCase(lossType)) {
            return Lists.newArrayList("food has been stolen", "food has been broken");
        }
        else {
            return Lists.newArrayList("glass has been stolen", "glass has been stolen");
        }
    }
}
